Conversation
|
@elprans Hi! Please could you kindly take a look at this PR? We've faced the same problem with difficulties of Records' pickling :( |
| ): | ||
| await self.connect(record_class=MyRecordBad) | ||
|
|
||
| def test_record_pickle(self): |
There was a problem hiding this comment.
i suggest to write a test of pickling nested records
There was a problem hiding this comment.
Postgres doesn't support returning nested records. asyncpg doesn't support nested records anywhere. I don't think it's a good idea.
There was a problem hiding this comment.
Nested composite types are returned as nested Record instances, e.g:
import asyncio
import asyncpg
async def main():
conn = await asyncpg.connect()
await conn.execute('CREATE TYPE complex AS (r float, imag float)')
print(await conn.fetchrow("SELECT 1, '2', (3, 4)::complex"))
asyncio.run(main())| if (PyObject_Length(desc->mapping) != len) { | ||
| return NULL; | ||
| } | ||
| PyObject *record = ApgRecord_New(&ApgRecord_Type, (PyObject *)desc, len); |
There was a problem hiding this comment.
This would lose the original record subtype if one was used, so you need to pickle the class reference also.
|
OK, we seem to have different use cases and motivations with the maintainer here. Please feel free to close this PR since I am not planning any further work, unfortunately. If one doesn't leverage custom record classes and doesn't work with nested stuff, my fork is published and maintained as asyncpg-rkt on PyPi, together with many other improvements. |
I'm not sure how you reached this conclusion. I simply pointed out the inaccuracy of your statement regarding nested records which would need to be addressed for this to get merged. Other than that this is a valid and valuable improvement. |
Closes #451